<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>侦听事件-方法内逻辑</title>
  <script type="text/javascript" src="vue.js"></script>
</head>
<body>
  <div id="app">  
    <button v-on:click="changeLength">改变边长</button>
    <p>正方形的边长是{{length}}，面积是{{area}}。</p>
  </div>
  
  <script>
    let square = {length:2};
    let vm = new Vue({
      el:"#app", 
      data: square,
      computed: {
        area(){
          return this.length * this.length;
        }
      },
      methods: {
        changeLength(){
          this.length++;
        }
      }
    })
  </script>
</body>
</html>
